#include<stdio.h>
#include<stdlib.h>
#include "main.h"


int main(void){
    FILE *fp;
    // 初始化虚拟机
    VM_init();
    // 加载程序
    fp = fopen("./app.bin", "rb");
    if(fp == NULL){
        printf("打开文件失败\n");
        return -1;
    }
    fseek(fp, 0, SEEK_END);
    uint32_t size = ftell(fp);
    fseek(fp, 0, SEEK_SET);
    uint8_t *program = (uint8_t *)malloc(size);
    fread(program, 1, size, fp);
    fclose(fp);
    load_program(program, 0, size);
    // 运行程序
    VM_run();
}